<template>
  <div class="search">
    <el-input v-model="word" size="large" placeholder="按回车搜索" :suffix-icon="Search" @keydown.enter="search" />
  </div>
  <search-result :searchWord="searchWord" :wordList="wordList" />
</template>
<script lang="ts" setup>
import { open } from '@/api/open'
import SearchResult from '@/components/search/SearchResult.vue'
import { Search } from '@element-plus/icons-vue'
import { ref } from 'vue'
const word = ref('')
const searchWord = ref('')
const wordList = ref([])
const search = async () => {
  searchWord.value = word.value
  const msg = await open.word.getSearch({ word: word.value })
  if (msg.code === 0) {
    wordList.value = msg.data
  }
}
</script>
<style lang="scss" scoped>
.search {
  max-width: 980px;
  margin: 20px auto 10px;
}
</style>
